package MyArray;

/**
 * 请求出一个数组int[]的最大值{4,-1,9, 10,23}，并得到对应的下标。
 * @author Raymond
 * @create 2025/2/26 09:31
 */
public class ArrayExercise02 {
    public static void main(String[] args) {
        int[] array = {4,-1,23, 10,9};
        int max = array[0];
        int index = 0;
        for (int i = 0; i < array.length; i++) {
            if (max<=array[i])
            {
                max = array[i];
                index = i;
            }
        }
        System.out.println("max = " + max);
        System.out.println("index = " + index);
    }
}
